package com.example.codeger.jimmer;

import cn.hutool.core.collection.ListUtil;
import cn.hutool.db.ds.DSFactory;
import cn.hutool.setting.Setting;

import javax.sql.DataSource;
import java.sql.SQLException;

public class JimmerCodeGen {
    public static void main(String[] args) throws SQLException {

        Setting setting = new Setting();
        setting.set(DSFactory.KEY_ALIAS_URL[1], "jdbc:postgresql://localhost:5432/kupai_camunda722");
        setting.set(DSFactory.KEY_ALIAS_USER[1], "postgres");
        setting.set(DSFactory.KEY_ALIAS_PASSWORD[1], "lhl123");
        setting.set(DSFactory.KEY_ALIAS_DRIVER[1], "org.postgresql.Driver");
        //获取指定配置，第二个参数为分组，用于多数据源，无分组情况下传null
        // 注意此处DSFactory需要复用或者关闭
        DataSource ds = DSFactory.create(setting).getDataSource();


        JimmerEntitySourceBuilder entitySourceBuilder = JimmerEntitySourceBuilder.builder()
                .basePackage("com.example.gen")
                .dataSource(ds)
                .tables(ListUtil.toList("act_re_procdef"))
                .templateFilePath("templates/jimmer/entity.btl").build();


        entitySourceBuilder.handlerBeetl();
        //entitySourceBuilder.handlerJte();
    }
}